#include <iostream>
#include <functional>
#include <assert.h>

#include "lambda/lambda.hpp"

using namespace night::lambda;

int sum_1 (int x) { return x; }
int sum_2 (int x,int y) { return x+y; }
int sum_3 (int x,int y,int z) { return x+y+z; }

int main ()
{
	int i=1, j=2, k=3;

	assert ( bind (x, i) (sum_1) == 1 );
	assert ( bind (sum_1, x) (i) == 1 );
	assert ( (fun (x) [sum_1][x]) (i) == 1 );
	assert ( bind (x, i,y) (sum_2,j) == 3 );
	assert ( bind (sum_2, x,y) (i,j) == 3 );
	assert ( (fun (x,y) [sum_2][x,y]) (i,j) == 3 );
	assert ( bind (x, i,y,z) (sum_3,j,k) == 6 );
	assert ( bind (sum_3, x,y,z) (i,j,k) == 6 );
	assert ( (fun (x,y,z) [sum_3][x,y,z]) (i,j,k) == 6 );

	int s = bind (	sum_1,                  // 10
		bind (	sum_3,                  // 10
			bind (	sum_2,          // 3
				bind (sum_1,x), // 1
				y ),
			z,
			4)
	) ( i, j, k );
	assert ( s == 10 );

	assert ( bind ( std::plus<int>(),x,y )(i,i) == 2 );

}
